#include "next_track.h"

extern int G_W, G_H;

NEXT_TRACK::NEXT_TRACK(CASH *cash):QGraphicsObject()
{

    this->setZValue(1.0);

    im = cash->cash_pixmap->value("Res/HUD/track_background.png");

    this->setPos(G_W,150);

    anim_enemy = new QGraphicsItemAnimation();

    enemy_time_line = new QTimeLine(5000);                                             // Скорость перемещения обьекта по траектории
    enemy_time_line->setEasingCurve( QEasingCurve::Type(1));
    enemy_time_line->setFrameRange(0, 1);

    anim_enemy->setTimeLine(enemy_time_line);
    anim_enemy->setItem(this);

    anim_enemy->setPosAt(0,QPointF(G_W,150) );
    anim_enemy->setPosAt(0.1,QPointF(G_W-im->width(),150));
    anim_enemy->setPosAt(0.2,QPointF(G_W-im->width(),150));
    anim_enemy->setPosAt(0.3,QPointF(G_W-im->width(),150));
    anim_enemy->setPosAt(0.4,QPointF(G_W-im->width(),150));
    anim_enemy->setPosAt(0.5,QPointF(G_W-im->width(),150));

    anim_enemy->setPosAt(1,QPointF(G_W,150));

    enemy_time_line->start();

    connect(enemy_time_line,SIGNAL(finished()),SLOT(deleteLater()));

}

QRectF NEXT_TRACK::boundingRect() const
{

    return QRectF();

}

void NEXT_TRACK::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{

    painter->save();
    painter->drawPixmap( 0,0,*im);
    painter->restore();

}

NEXT_TRACK::~NEXT_TRACK()
{
}
